//@author A0097978X
package flexiCommands;

import java.io.File;
import java.util.*;
import java.util.logging.FileHandler;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
//import flexiCommands.*;
//import storage.*;

public class TestFlexi {

	public static void main(String[] args) {
		
		Logger logger = Logger.getLogger("MyLog");
		FileHandler fh;
		
/* Boundary Cases:
 * 	
 * For input, Command Type must be either [add]|[remove]|[display]|[edit]|[pending]|[complete]|[undo]|[exit]
 * 									   or [any other String]
 * 									   or [null]
 * 
 * For [add], string length can be of any length
 * For [remove]|[display]|[edit]|[pending]|[complete], "Integer" and w/o "Integer"
 * For [undo]|[exit], string length of just one and of any. 
 */
		
		try {
			fh = new FileHandler("TestLog.log");
			logger.addHandler(fh);
			SimpleFormatter formatter = new SimpleFormatter();  
	        fh.setFormatter(formatter); 
			
	        logger.info("Start Test");
	        
			//Scanner sc = new Scanner(System.in);
	        Scanner sc = new Scanner(new File("TestCases.txt"));
	        int count = Integer.parseInt(sc.nextLine());
	        
			//System.out.println("Please enter command: ");
			String userCommand = sc.nextLine();
			
			logger.info("User added: \"" + userCommand + "\"");
			
			while(count != 1) {
				Command testing = FlexiCommandGenerator.generateCommands(userCommand);

				System.out.println();
				System.out.println("Command Type: " + testing.getCommandType());
			
				System.out.println();
				System.out.println("Description: " + testing.getDescription());
				System.out.println("Start Date: D " + testing.getDateRange().getStartDate().getDay() + " M " + testing.getDateRange().getStartDate().getMonth() + " Y " + testing.getDateRange().getStartDate().getYear());
				System.out.println("End Date: D " + testing.getDateRange().getEndDate().getDay() + " M " + testing.getDateRange().getEndDate().getMonth() + " Y " + testing.getDateRange().getEndDate().getYear());
				System.out.println("Start Time: H " + testing.getTimeRange().getStartTime().getHour() + " M " + testing.getTimeRange().getStartTime().getMinute() + " S " + testing.getTimeRange().getStartTime().getSecond());
				System.out.println("End Time: H " + testing.getTimeRange().getEndTime().getHour() + " M " + testing.getTimeRange().getEndTime().getMinute() + " S " + testing.getTimeRange().getEndTime().getSecond());
			
				System.out.println();
				System.out.println("Query: " + testing.getQuery());
				System.out.println("Option: " + testing.getOption());
				
				System.out.println();
				//System.out.println("Please enter command: ");
				userCommand = sc.nextLine();
				logger.info("User added: \"" + userCommand + "\"");
				System.out.println();
				
				count--;
			}
		} catch (Exception e) {
			logger.info("Warning message: \"" + e.getMessage() + "\"");
			System.err.println(e.getMessage());
		}  
	}

}
	